# !/usr/bin/env python
# -*-coding:utf-8 -*-

"""
# File       : word2vec.py
# Time       ：2021/2/25 15:54
# Author     ：author name
# version    ：python 3.6
# Description：
"""

from gensim.models import Word2Vec,KeyedVectors

path="a.bin"
common_texts=[["我国脱贫攻坚战取得了全面胜利，现行标准下9899万农村贫困人口全部脱贫，832个贫困县全部摘帽，12.8万个贫困村全部出列，区域性整体贫困得到解决，完成了消除绝对贫困的艰巨任务，创造了又一个彪炳史册的人间奇迹！"]]
sentenses=[['Hold', 'on,', 'little', 'Show', 'what', "he's", 'done', 'boring','like','to', 'Stand', 'up,', 'little', 'A', 'broken', 'heart', "can't", 'that', 'bad', 'When', "it's", 'through,', "it's", 'through', 'Fate', 'will', 'twist', 'both', 'of', 'So', 'come', 'on,', 'Come', 'over', 'Let', 'one', 'to', 'show', "I'm", 'one', 'who', 'wants', 'to', 'with', 'Deep', 'inside', 'hope', 'feel', 'it', 'too', 'Waited', 'a', 'line', 'of', 'greens', 'blues', 'Just', 'to', 'next', 'to', 'with', 'Build', 'up', 'your', 'confidence', 'So', 'can', 'top', 'for', 'once', 'Wake', 'up', 'whom', 'cares', 'about', 'Little', 'boys', 'that', 'talk', 'too', 'much', 'see', 'it', 'all', 'go', 'down', 'Your', 'game', 'of', 'love', 'was', 'all', 'rained', 'out', 'So', 'come', 'on,', 'Come', 'over', 'Let', 'one', 'to', 'hold', 'Why', 'alone', 'when', 'we', 'can', 'together,', 'baby', 'You', 'can', 'make', 'life', 'worthwhile', 'And', 'can', 'make', 'start', 'to', 'smile'], ['same', 'must', 'strong', 'carry', 'on,', "don't", 'belong', 'here', 'hold', 'hand', 'help', 'stand', "I'll", 'find', 'way', 'through', 'night', 'day,', 'just', "can't", 'stand', 'here', 'Time', 'can', 'bring', 'down,', 'Time', 'can', 'bend', 'your', 'knees,', 'Time', 'can', 'break', 'your', 'Have', 'begging', 'please,', 'Begging', 'Beyond', 'door', "there's", 'peace', "I'm", 'sure', 'And', "there'll", 'no', 'more', 'tears', 'same', 'must', 'strong', 'carry', 'on,', "don't", 'belong', 'here']]


song1="Hold on, little girl  Show me what he's done to you Stand up, little girl A broken heart can't be that bad When it's through, it's through Fate will twist the both of you So come on, baby. Come on over Let me be the one to show you I'm the one who wants to be with you Deep inside I hope you feel it too  Waited on a line of greens and blues Just to be the next to be with you Build up your confidence  So you can be on top for once Wake up whom cares about Little boys that talk too much  I see it all go down Your game of love was all rained out So come on, baby. Come on over Let me be the one to hold you  Why be alone when we can be together, baby  You can make my life worthwhile And I can make you start to smile"
model = Word2Vec(sentences=sentenses,size=200,window=5,min_count=1,workers=4,sg=1,iter=50)
print("Hold",model['Hold'])
s1=model.similarity("boring","like")
print(s1)
exit()


model.save(path)
a_model=model.wv.save_word2vec_format(path, binary=False)
print(model.wv.vocab.items())
for i in model.wv.vocab.items():
    print(i)
# 加载bin格式的模型
wordVec = KeyedVectors.load_word2vec_format(path,binary=True)
print(wordVec.vocab)
for key in wordVec.similar_by_word('Fate',topn=5):
    print(key)
# l_model=Word2Vec.load(path)
# print(l_model)
# vec=l_model['Show']
# for i in l_model:
#     print(i)
# for i in l_model.a